(() => {
    // 混合类型
    // 有点像构造函数
    // 1.函数类型的interface，添加属性的方式来实现，对象的interface
    interface Counter {
        (start: number): string
        interval: number
        reset(): void
    }
    function getCounter(): Counter {
        let counter = <Counter>function (start: number) { }
        counter.interval = 123
        counter.reset = function () { }
        return counter
    }
    let c = getCounter()
    console.log(c.interval);


    // 2.混合类型的应用
    
    // 描述实例部分
    interface ClockInterface {
        currentDate: Date
        getTime(): void
    }
    // 描述静态部分
    interface ClockCounstructor {
        new(h: number, m: number)
        getTimeStatic(): void
    }

    function createdClock(C: ClockCounstructor, h: number, m: number): ClockInterface {
        return new C(h, m)
    }
    class Clcok implements ClockInterface {
        // 实现实例部分属性和方法
        h: number
        m: number
        currentDate = new Date()
        getTime() {
            console.log(`现在是${this.h}小时${this.m}分`);
        }

        // 实现静态方法
        constructor(h: number, m: number) {
            this.h = h
            this.m = m
        }
        static getTimeStatic() {
            console.log('静态方法');
        }
    }
    let clock = createdClock(Clcok, 3, 15)
    Clcok.getTimeStatic()
    clock.getTime()

})()